package com.mrtan.service.impl;

import com.mrtan.bean.Account;
import com.mrtan.mapper.AccountMapper;
import com.mrtan.service.AccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 账号
 * @author 李聪
 * @version 2023/12/6
 */
@Service
public class AccountServiceImpl implements AccountService {
    @Resource
    private AccountMapper accountMapper;
    @Override
    public Account findById(Integer id) {
        Account account = accountMapper.selectByPrimaryKey(id);
        if (account != null) {
            account.setPassword(null);
        }
        return account;
    }

    @Override
    public Account findByUsernameAndPassword(String username, String password) {
        Account account = accountMapper.findByUsernameAndPassword(username, password);
        if (account != null) {
            account.setPassword(null);
        }
        return account;
    }

    @Override
    public List<Account> selectAllAccounts() {
        List<Account> accounts = accountMapper.selectAllAccounts();
        return accounts;
    }
}
